<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script
      src="https://cdn.bootcdn.net/ajax/libs/vue/3.2.40/vue.global.js"
      type="application/javascript"
    ></script>
  </head>
  <body>
    <!-- 准备个容器 -->
    <div id="app">
      <!-- 插值表达式允许我们在里面书写js表达式 -->
      <!-- 1.a
      2.a+b 
      3.add()
      4.x===1 ? 'a' :  'y' -->
      {{msg}}-----
      <span v-once>{{a}} </span>
      ----- {{a+b}} ----- {{a===1 ? 'a' : 'y'}}
      <p>******{{add2('tom')}}</p>
      <p>{{rawHtml}}</p>
      <p>v-html:<span v-html="rawHtml"></span></p>
      <button v-on:click="add($event,a, b)">+++</button>
    </div>

    <script>
      const myDom = document.getElementById("app");
      const app = Vue.createApp({
        data() {
          return {
            msg: "hello world",
            a: 1,
            b: 2,
            rawHtml: "<div>html文本<span>{{abc}}</span></div>", //v-html会忽略解析属性值中的数据绑定
            abc: "abc",
          };
        },
        methods: {
          add(e, a, b) {
            // this.$data.a++;
            this.a++;
            console.log(e.target, a, b);
            e.target.innerHTML = "abc"; //操作真实DOM的方法，不推荐
          },
          add2(params) {
            console.log(params);
          },
        },
      });
      let vm = app.mount(myDom);
      console.log(vm);
      console.log(vm.$data.msg);
      console.log(vm.$data.msg === vm.msg);
      vm.a = 5;
      console.log(vm.a);
    </script>
  </body>
</html>
